#!/bin/sh
# update-pciids for puppy linux

#-------------------------------------------
#URL="http://pci-ids.ucw.cz/pci.ids"
URL="http://pci-ids.ucw.cz/v2.2/pci.ids.bz2"
#-------------------------------------------

[ "$ROOTDIR" ] || ROOTDIR="${ROOTDIR}"
[ -d "$1" ] && ROOTDIR="$1"
ROOTDIR=${ROOTDIR%/}

exit_error() {
	echo "$@"
	exit 1
}

mkdir -p ${ROOTDIR}/usr/share/hwdata
mkdir -p ${ROOTDIR}/usr/share/misc

wget --no-check-certificate -O ${ROOTDIR}/usr/share/hwdata/pci.ids.bz2 $URL || exit_error "error downloading pci.ids.bz2"

rm -f ${ROOTDIR}/usr/share/hwdata/pci.ids 2>/dev/null
rm -f ${ROOTDIR}/usr/share/misc/pci.ids 2>/dev/null
rm -f ${ROOTDIR}/usr/share/pci.ids 2>/dev/null

bunzip2 ${ROOTDIR}/usr/share/hwdata/pci.ids.bz2 || exit_error "error uncompressing pci.ids.bz2"
ln -sf ../../../usr/share/hwdata/pci.ids ${ROOTDIR}/usr/share/misc/pci.ids
ln -sf ../../usr/share/hwdata/pci.ids ${ROOTDIR}/usr/share/pci.ids

echo pci.ids $(grep -o 'Version: .*' ${ROOTDIR}/usr/share/misc/pci.ids)

### END ###
